package com.takeeasy.project.baiqin.action.org;

import java.util.ArrayList;
import java.util.List;

import com.takeeasy.platform.action.BaseAction;
import com.takeeasy.platform.annotation.Action;
import com.takeeasy.platform.dataobject.RequestDataObject;
import com.takeeasy.platform.dataobject.ResponseDataObject;
import com.takeeasy.platform.util.DBUtil;
import com.takeeasy.project.baiqin.bo.org.MenuBo;

@Action(name = "MenuAction")
public class MenuAction extends BaseAction {
	public ResponseDataObject getDefaultTopMenu(RequestDataObject req) {
		String type = req.getParams().get("type");
		String locate = req.getParams().get("locate");
		String sql ="select * from t_org_default_menu";
		sql = DBUtil.addSQLParameter(sql, "menu_type", "and");
		sql = DBUtil.addSQLParameter(sql, "menu_locate", "and");
		List<Object> params = new ArrayList<>();
		params.add(type);
		params.add(locate);
		List<MenuBo> menuList = getDao().query(MenuBo.class, sql.toString(), params);
		getResponseData().addToResponseMap("menuList", menuList);
		return getResponseData();
	}
	
	public ResponseDataObject gotoMenuListPage(RequestDataObject req){
		getResponseData().setRedirectPage("admin/jsp/menuList.jsp");
		return getResponseData();
	}
	
	public ResponseDataObject  getDefaultChildMenu(RequestDataObject req) {
		String parentId = req.getParams().get("parentId");
		String sql ="select * from t_org_default_menu";
		sql = DBUtil.addSQLParameter(sql, "menu_parent_id", "and");
		List<Object> params =new ArrayList<>();
		params.add(parentId);
		List<MenuBo> menuList = getDao().query(MenuBo.class, sql, params);
		getResponseData().addToResponseMap("menuList", menuList);
		return getResponseData();
	}
}
